package com.kanshu.ksgb.fastread.doudou.module.signin.widget;

import java.util.Random;

/**
 * Title: RandomGenerator.java
 * Description: 随机生成器
 * Copyright: Copyright(c)2017
 * Company: 成都古羌科技有限公司
 * CreateTime: 2017/12/21 9:42
 *
 * @author EvanHe
 * @version 1.0
 */
public class RandomGenerator {
    private static final Random RANDOM = new Random();

    // 区间随机
    public float getRandom(float lower, float upper) {
        float min = Math.min(lower, upper);
        float max = Math.max(lower, upper);
        return getRandom(max - min) + min;
    }

    // 上界随机
    public float getRandom(float upper) {
        return RANDOM.nextFloat() * upper;
    }

    // 上界随机
    public int getRandom(int upper) {
        return RANDOM.nextInt(upper);
    }
}

